
package org.apache.solr.handler.component;

import java.util.Map;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.common.util.NamedList;

/**
 * StatsValue defines the interface for the collection of statistical values about fields and facets.
 */
public interface StatsValues {

    /**
     * Accumulate the values based on those in the given NamedList
     *
     * @param stv NamedList whose values will be used to accumulate the current values
     */
    void accumulate(NamedList stv);

    /**
     * Accumulate the values based on the given value
     *
     * @param value Value to use to accumulate the current values
     */
    void accumulate(BytesRef value);

    /**
     * Accumulate the values based on the given value
     *
     * @param value Value to use to accumulate the current values
     * @param count number of times to accumulate this value
     */
    void accumulate(BytesRef value, int count);

    /**
     * Updates the statistics when a document is missing a value
     */
    void missing();

    /**
     * Updates the statistics when multiple documents are missing a value
     *
     * @param count number of times to count a missing value
     */
    void addMissing(int count);

    /**
     * Adds the facet statistics for the facet with the given name
     *
     * @param facetName Name of the facet
     * @param facetValues Facet statistics on a per facet value basis
     */
    void addFacet(String facetName, Map<String, StatsValues> facetValues);

    /**
     * Translates the values into a NamedList representation
     *
     * @return NamedList representation of the current values
     */
    NamedList<?> getStatsValues();
}
